.PHONY: proto user order client build db-up db-down db-init clean deps test-http demo-http config-tool config-create config-validate config-show test-config

proto:
	protoc --go_out=. --go-grpc_out=. proto/*.proto

user:
	go run services/user/main.go

order:
	go run services/order/main.go

client:
	go run client/main.go

build:
	mkdir -p bin
	go build -o bin/user services/user/main.go
	go build -o bin/order services/order/main.go
	go build -o bin/client client/main.go

# 数据库相关命令
db-up:
	docker-compose up -d

db-down:
	docker-compose down

db-init:
	mysql -h localhost -u root -p -e "source scripts/init_db.sql"

# 清理构建文件
clean:
	rm -rf bin/

# 测试 HTTP API
test-http:
	./scripts/test_http_api.sh

# HTTP API 演示
demo-http:
	./scripts/demo_http.sh

# 配置管理工具
config-tool:
	go build -o bin/config-tool cmd/config-tool/main.go

config-create:
	go run cmd/config-tool/main.go -action=create -path=./configs/config.yaml

config-validate:
	go run cmd/config-tool/main.go -action=validate

config-show:
	go run cmd/config-tool/main.go -action=show

# 测试配置系统
test-config:
	./scripts/test_config.sh

deps:
	go mod tidy
